package Day02;

import java.util.ArrayList;
import java.util.Collections;

/**
 * 高精度乘法
 * C = A * b
 */
public class Mul {

    public static ArrayList<Integer> mul(ArrayList<Integer> A, int b) {
        ArrayList<Integer> res = new ArrayList<>();
        // 用来表示存进去的值
        int t = 0;
        for (int i = 0; i < A.size() || t != 0; i++) {
            if (i < A.size()) t += A.get(i) * b;
            res.add(t % 10);
            t /= 10;
        }
        return res;
    }

    public static void main(String[] args) {
        String a = "2333";
        int b = 15;
        ArrayList<Integer> A = new ArrayList<>();
        ArrayList<Integer> res = new ArrayList<>();
        for (int i = a.length() - 1; i >= 0; i--) {
            A.add(a.charAt(i) - '0');
        }
        res = mul(A, b);
        Collections.reverse(res);
        for (int i = 0; i < res.size(); i++) {
            System.out.print(res.get(i));
        }
    }


}
